const {
  getRecommentPetsList
} = require('../../api/pets')
const {
  getnotice,
  addNum
} = require('../../api/notice')


Page({
  onShareAppMessage() {
    return {
      title: 'swiper',
      path: 'page/component/pages/swiper/swiper'
    }
  },

  data: {
    recommentPetsList: [],
    noticeList: [],
    background: ['http://localhost:3000/bg1.jpg', 'http://localhost:3000/bg10.jpg', 'http://localhost:3000/bg9.jpg'],

  },
  goDetail(event) {
    // console.log(event.currentTarget.dataset.id);
    wx.navigateTo({
      url: `/pages/petsDetail/petsDetail?id=${event.currentTarget.dataset.id}`,
    })
  },
  goNotice(event) {
    // console.log(event.currentTarget.dataset.id);
    addNum(event.currentTarget.dataset.id)

    wx.navigateTo({
      url: `/pages/Notice/Notice?id=${event.currentTarget.dataset.id}`,
    })
  },
  // 页面展示请求数据
  onShow() {
    getRecommentPetsList(res => {
      // console.log(res);
      this.setData({
        recommentPetsList: res.data.list
      })
    })
    getnotice(res => {
      // console.log(res);
      this.setData({
        noticeList: res.data.newsResult
      })
    })
  }
})